﻿Imports System.Data
Imports System.Data.SqlClient
Public Class Cargas_agendamentoDAL
    Public Sub New()

    End Sub
    Dim cmd As SqlCommand
    Dim objD As Dados
#Region "Métodos"
    Public Sub inserirCargas(ByVal age_codigo As Integer, ByVal car_codigo As Integer)
        Try
            cmd = New SqlCommand()
            objD = New Dados()
            cmd.CommandText = "insert into cargas_do_agendamento(age_codigo,car_codigo)values(@age_codigo,@car_codigo)"
            cmd.Parameters.Add(New SqlParameter("@age_codigo", SqlDbType.Int)).Value = age_codigo
            cmd.Parameters.Add(New SqlParameter("@car_codigo", SqlDbType.Int)).Value = car_codigo
            objD.executacomando(cmd)
        Catch ex As Exception
            Throw ex
        End Try
        cmd = Nothing
        objD = Nothing
    End Sub
    Public Sub alterarCarga(ByVal age_codigo As Integer, ByVal car_codigo As Integer)
        Try
            cmd = New SqlCommand()
            objD = New Dados()
            cmd.CommandText = "update cargas_do_produto set car_codigo = @car_codigo where age_codigo = @age_codigo"
            cmd.Parameters.Add(New SqlParameter("@car_codigo", SqlDbType.Int)).Value = car_codigo
            cmd.Parameters.Add(New SqlParameter("@age_codigo", SqlDbType.Int)).Value = age_codigo
            objD.executacomando(cmd)
        Catch ex As Exception
            Throw ex
        End Try
        cmd = Nothing
        objD = Nothing
    End Sub
    Public Sub excluirCarga(ByVal age_codigo As Integer)
        Try
            cmd = New SqlCommand()
            objD = New Dados()
            cmd.CommandText = "delete from cargas_do_agendamento where age_codigo = @age_codigo"
            cmd.Parameters.Add(New SqlParameter("@age_codigo", SqlDbType.Int)).Value = age_codigo
            objD.executacomando(cmd)
        Catch ex As Exception
            Throw ex
        End Try
        cmd = Nothing
        objD = Nothing
    End Sub
    Public Function localizarCargas(age_codigo As Integer)
        Dim tab As DataTable
        Try
            cmd = New SqlCommand()
            objD = New Dados()
            cmd.CommandText = "select * from cargas_do_agendamento where age_codigo = @age_codigo"
            cmd.Parameters.Add(New SqlParameter("@age_codigo", SqlDbType.Int)).Value = age_codigo
            tab = objD.executaConsulta(cmd)
        Catch ex As Exception
            Throw ex
        End Try
        cmd = Nothing
        objD = Nothing
        Return tab
    End Function
#End Region
End Class
